<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    //类继承与super关键字
    /*   class Father {
           constructor() {
           }
           sing(){
               console.log("我是父类的方法")
           }
       }

       class Son extends Father {

       }
       let son = new Son();
       son.sing()*/

    /*    class Father {
            constructor(x, y) {
                this.x = x;
                this.y = y;
            }

            sum() {
                console.log(this.x + this.y)
            }

            sing() {
                console.log("我是父类的方法")
            }
        }

        class Son extends Father {
            constructor(x, y) {
                super(x, y);//调用父类的构造方法。super必须放在this之前
            }
        }

        let son = new Son(1, 2);
        son.sum();
        son.sing();*/

    class Father {
        say() {
            console.log("父类的方法")
        }

        say2() {
            return "父类的方法";
        }
    }

    class Son extends Father {
        say() {
            console.log("子类的方法 ")
        }

        //子类调用父类的普通方法
        say2() {
            console.log(super.say2(), "子类来调用")
        }

    }

    let son = new Son();
    son.say();
    son.say2();
</script>
</body>
</html>
